package com.linwen.excise.leetcode;

import com.linwen.dataStructure.tree.BinaryTree;

import java.util.Arrays;
import java.util.LinkedList;

/**
 * @author : linwen
 * @date : 10:49 下午 2020/10/27
 */
public class _144二叉树的前序遍历 {
    public static void main(String[] args) {
        //构造二叉树
        LinkedList<Integer> inputList = new LinkedList<Integer>
                (Arrays.asList(new Integer[] {1,null,2,3}));
        new BinaryTree();
        com.linwen.dataStructure.tree.TreeNode treeNode = BinaryTree.creatBinaryTree(inputList);
        //二叉树前序遍历
        prev(treeNode);
    }

    private static void prev(com.linwen.dataStructure.tree.TreeNode treeNode) {
        if(treeNode==null){
            return;
        }
        System.out.print(treeNode.data+" ");
        prev(treeNode.leftNode);
        prev(treeNode.rightNode);
    }
}




